package io.kiki.task.common.core.rpc;

import io.kiki.task.common.core.model.Result;
import lombok.Getter;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;


@Getter
public class Future<R extends Result<Object>> extends CompletableFuture<R> {
    private final Long requestId;
    private final long timeout;
    private final TimeUnit timeUnit;

    public Future(Long requestId, long timeout, TimeUnit timeUnit) {
        this.requestId = requestId;
        this.timeout = timeout;
        this.timeUnit = timeUnit;
    }

    public static <R extends Result<Object>> Future<R> newFuture(Long requestId, long timeout, TimeUnit unit) {
        return new Future<>(requestId, timeout, unit);
    }

}
